<template>
  <a-breadcrumb class="container-breadcrumb">
    <a-breadcrumb-item>
      <a-tooltip v-if="items.length > 1" :title="$t('breadcrumb.tooltip.back')" color="#87d068">
        <RollbackOutlined @click="goBack" />
      </a-tooltip>
      <AppstoreOutlined v-else />
    </a-breadcrumb-item>
    <a-breadcrumb-item v-for="item in items" :key="item">
      {{ $t(item) }}
    </a-breadcrumb-item>
  </a-breadcrumb>
</template>

<script lang="ts" setup>
import { PropType } from "vue"
import { AppstoreOutlined, RollbackOutlined } from "@ant-design/icons-vue"
import { useRouter } from "vue-router"

defineProps({
  items: {
    type: Array as PropType<string[]>,
    default() {
      return []
    }
  }
})
const router = useRouter()

const goBack = () => {
  router.back()
}
</script>

<style scoped lang="scss">
.container-breadcrumb {
  margin: 16px 0;

  :deep(.ant-breadcrumb-link) {
    color: rgb(134, 144, 156);

    &:last-child {
      color: rgb(78, 89, 105);
    }
  }
}
</style>
